from Untils.SendMethod import SendMethod
from Interface.DHX_MemberInterface import MemberInterface


class MemberReadHistoryController:

    def __init__(self):
        self.url = 'http://139.159.146.104:8083'

    def member_readHistory_create(self, memberId, productId):
        """
        创建浏览记录
        :return:
        """
        mi = MemberInterface()
        headers = mi.get_token(username='liar', password='123456')
        payload = {
            "memberId":memberId,
            "productId":productId
        }
        url = self.url + '/member/readHistory/create'
        return SendMethod.send_method(method='post', url=url, json=payload, headers=headers)

    def member_readHistory_delete(self, ids):
        """
        删除浏览记录
        :return:
        """
        mi = MemberInterface()
        headers = mi.get_token(username='liar', password='123456')
        payload = {
            'ids': ids
        }
        url = self.url + '/member/readHistory/delete'
        return SendMethod.send_method(method='post', url=url, data=payload, headers=headers)

    def member_readHistory_list(self,memberId):
        """
        展示浏览记录
        :return:
        """
        mi = MemberInterface()
        headers = mi.get_token(username='liar', password='123456')
        payload = {
            'memberId': memberId
        }
        url = self.url + '/member/readHistory/list'
        return SendMethod.send_method(method='get', url=url, params=payload, headers=headers)


if __name__ == '__main__':
    me = MemberReadHistoryController()
    # print(me.member_readHistory_create('2','2'))
    # print(me.member_readHistory_delete('2'))
    print(me.member_readHistory_list('2'))
